package top.truehaku.generator.code.domain.model.table;



import lombok.Getter;
import lombok.Setter;
import top.truehaku.generator.common.domain.ValueObject;
import top.truehaku.generator.common.util.StringUtils;

public class TableId implements ValueObject<TableId> {

    @Getter@Setter
    private String tableScheme;

    @Getter@Setter
    private String tableName;

    public TableId(final String tableScheme,final String tableName) {
        if (StringUtils.isEmpty(tableScheme)){
            throw new IllegalArgumentException("数据库库名不能为空");
        }
        if (StringUtils.isEmpty(tableName)){
            throw new IllegalArgumentException("表名不能为空");
        }
        this.tableScheme = tableScheme;
        this.tableName = tableName;
    }

    @Override
    public boolean sameValueAs(TableId other) {
        return  other!=null
                &&this.tableScheme.equals(other.tableScheme)
                &&this.tableName.equals(other.tableName);
    }

}
